package com.avalon.shop.schedule;

import com.avalon.shop.service.ShopService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class LoginSchedule {
    private ShopService shopService;

    public LoginSchedule(ShopService shopService) {
        this.shopService = shopService;
    }

    @Scheduled(fixedRate = 5000) // 每5s
    public void validateLogin() {
        if (!shopService.validateLogin()) {
            shopService.backLogin();
        }
    }
}
